﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Web.API.IBLL;
using Web.API.Model;

namespace Web.API.UI.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        public UserController(UserIBLL bll, ILogger<UserController> logger) 
        {
            Bll = bll;
            Logger = logger;
        }
        public UserIBLL Bll { get; }
        public ILogger<UserController> Logger { get;}
        [HttpPost("AddUser")]
        public Task<int> AddUser(UserModel user)
        {
            try
            {
                Logger.LogInformation("添加成功");
                return Bll.AddUser(user);
            }
            catch (Exception)
            {
                throw;
            }
            
        }
        [HttpDelete("DelUser")]
        public Task<int> DelUser(string ids)
        {
            try
            {
                Logger.LogInformation("删除成功");
                return Bll.DelUser(ids);
            }
            catch (Exception)
            {
                throw;
            }
            
        }
        [HttpGet("Fantian")]
        public UserModel Fantian(int id)
        {
            try
            {
                Logger.LogInformation("反填成功");
                return Bll.Fantian(id);
            }
            catch (Exception)
            {
                throw;
            }
            
        }
        [HttpGet("GetUser")]
        public dynamic GetUser(string? name, int usertypeid, int index, int size)
        {
            try
            {
                Logger.LogInformation("显示成功");
                return Bll.GetUser(name, usertypeid, index, size);
            }
            catch (Exception)
            {
                throw;
            }
           
        }
        [HttpGet("UptStart")]
        public Task<int> UptStart(string idstring)
        {
            try
            {
                Logger.LogInformation("状态修改成功");
                return Bll.UptStart(idstring);
            }
            catch (Exception)
            {
                throw;
            }
           
        }
        [HttpPut("UptUser")]
        public Task<int> UptUser(UserModel user)
        {
            try
            {
                Logger.LogInformation("修改成功");
                return Bll.UptUser(user);
            }
            catch (Exception)
            {
                throw;
            }
           
        }
        [HttpGet("Xiala")]
        public List<UserTypeModel> Xiala()
        {
            try
            {
                return Bll.Xiala();
            }
            catch (Exception)
            {
                throw;
            }
           
        }

    }
}
